{include file="public/layout" /}
<body>
  <div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-row">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="web-system">
            <div class="layui-tab layui-tab-card">
              {include file="system/bar" /}
              <div class="layui-tab-content" style="padding:10px 0">
                <div class="layui-tab-item layui-show">
                  <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                      <div class="layui-card">
                        <div class="layui-card-body" pad15>
                          <div class="layui-form" wid100>
                            <div class="layui-form-item">
                              <label class="layui-form-label">网站状态</label>
                              <div class="layui-input-block">
                                <input type="checkbox" lay-filter="web_status" lay-skin="switch" lay-text="开启|关闭" {if condition="!isset($config.web_status) OR $config.web_status eq 1"}checked{/if}>
                                <input type="hidden" name="web_status" value="{$config.web_status|default='0'}" />
                              </div>
                            </div>
                            <div class="layui-form-item ey-text">
                              <label class="layui-form-label">网站简称</label>
                              <div class="layui-input-inline">
                                <input type="text" id="web_name" name="web_name" value="{$config.web_name|default=''}" class="layui-input ey-input" data-num="10">
                              </div>
                              <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">一般不超过10个字符</div>
                              <div class="layui-form-inline2 ey-big-text none">一般不超过10个字符（<span class="ey-textTips">还可以输入10个字符</span>）</div>
                            </div>
                            <div class="layui-form-item">
                              <label class="layui-form-label">网站LOGO</label>
                              <div class="layui-input-inline">
                                <div class="upload-box">
                                  <div class="upload-img fl">
                                    <div class="icaction none">
                                      <span class="load_images">
                                         <a href="javascript:void(0);" onclick="BigImages($('#img_web_logo').attr('src'));">
                                         <i class="layui-icon layui-icon-search mr5"></i>查看
                                         </a>
                                      </span>
                                      <span class="load_images">
                                        <a href="javascript:void(0);" data-inputid="web_logo" onclick="DelImages(this);">
                                        <i class="layui-icon layui-icon-delete mr5"></i>删除
                                        </a>
                                      </span>
                                    </div>
                                    <div class="cover-bg none"></div>
                                    <img id="img_web_logo" src="{$config.web_logo|get_default_pic=###}?v={php}echo time();{/php}">
                                  </div>
                                  <div class="upload-right fl">
                                    <button class="layui-btn test-upload-demoMore layui-btn-primary layui-btn-sm fl mb10 mr5" lay-data="{number:1,ey_inputId:'web_logo',ey_savepath:'allimg'}"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <button class="layui-btn layui-btn-sm layui-btn-primary layui-btn-sm fl mb10" onClick="GetPictureFolder(1,'web_logo');"><i class="layui-icon">&#xe64a;</i>图库</button>
                                    <input name="web_logo" id="web_logo" placeholder="图片地址" value="{$config.web_logo|default=''}" class="layui-input">
                                    <input type="hidden" name="old_web_logo" value="{$config.web_logo|default=''}" class="layui-input">
                                  </div>
                                </div>
                              </div>
                              <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                <div class="ey_helptips_txt">默认网站LOGO，通用头部显示，显示尺寸以模板设计为主</div>
                              </div>
                            </div>
                            <div class="layui-form-item">
                              <label class="layui-form-label">地址栏图标</label>
                              <div class="layui-input-inline">
                                <div class="upload-box">
                                  <div class="fl mr20">
                                    <img id="img_web_ico" src="{$config.web_ico}?v={php}echo time();{/php}" width="32" height="32">
                                  </div>
                                  <div class="upload-right fl">
                                    <button class="layui-btn test-upload-demoMore layui-btn-primary layui-btn-sm fl mb10 mr5" lay-data="{number:1,exts:'ico',ey_inputId:'web_ico',ey_savepath:'allimg'}"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <input type="hidden" name="web_ico" id="web_ico" placeholder="图片地址" value="{$config.web_ico|default=''}" class="layui-input">
                                  </div>
                                </div>
                              </div>
                              <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <div class="layui-form-mid layui-word-aux ey_helptips"></div>
                                <div class="ey_helptips_txt">建议尺寸 32 * 32 (像素) 的.ico文件。<br/>如果无法正常显示新上传图标，清空浏览器缓存后访问。</div>
                              </div>
                            </div>
                            <div class="layui-form-item">
                              <label class="layui-form-label">网站域名</label>
                              <div class="layui-input-inline">
                                <input type="text" name="web_basehost" value="{$config.web_basehost|default=''}" placeholder="{$Request.scheme}://" class="layui-input">
                              </div>
                            </div>
                            <div class="layui-form-item ey-text">
                              <label class="layui-form-label">首页标题</label>
                              <div class="layui-input-inline">
                                <input type="text" id="web_title" name="web_title" lay-verify="title" placeholder="一般不超过80个字符" value="{$config.web_title|default=''}" class="layui-input ey-input" data-num="80">
                              </div>
                              <div class="layui-input-inline layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">一般不超过80个字符</div>
                              <div class="layui-form-inline2 ey-big-text none">一般不超过80个字符（<span class="ey-textTips">还可以输入80个字符</span>）</div>
                            </div>
                            <div class="layui-form-item ey-text">
                              <label class="layui-form-label">首页关键词</label>
                              <div class="layui-input-inline">
                                <input type="text" name="web_keywords" lay-verify="title" value="{$config.web_keywords|default=''}" placeholder="一般不超过100个字符" class="layui-input ey-input" data-num="100">
                              </div>
                              <div class="layui-input-inline layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">一般不超过100个字符</div>
                              <div class="layui-form-inline2 ey-big-text none">一般不超过100个字符<span class="ey-textTips">还可以输入100个字符</span>）</div>
                            </div>
                            <div class="layui-form-item layui-form-text ey-text">
                              <label class="layui-form-label">首页描述</label>
                              <div class="layui-input-inline">
                                <textarea id="web_description" name="web_description" class="layui-textarea ey-input" placeholder="建议不超过200个字符" data-num="200">{$config.web_description|default=''}</textarea>
                              </div>
                              <div class="layui-input-inline layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">建议不超过200个字符</div>
                              <div class="layui-form-inline2 ey-big-text none">建议不超过200个字符<span class="ey-textTips">还可以输入200个字符</span>）</div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                              <label class="layui-form-label">版权信息</label>
                              <div class="layui-input-inline">
                                <textarea name="web_copyright" class="layui-textarea">{$config.web_copyright|default=''}</textarea>
                              </div>
                            </div>
                             <div class="layui-form-item">
                              <label class="layui-form-label">备案号</label>
                              <div class="layui-input-inline">
                                <input type="text" name="web_recordnum" lay-verify="title" value="{$config.web_recordnum|default=''}" class="layui-input">
                              </div>
                            </div>
                            <div class="layui-form-item ">
                              <label class="layui-form-label"><strong>自定义变量</strong></label>
                              <div class="layui-input-inline layadmin-layer-demo">
                                <button class="layui-btn layui-btn-sm" data-type="customvar_index">管理</button>
                              </div>
                            </div>
                            {volist name="eyou_row" id="vo"}
                            <div class="layui-form-item" id="dl_{$vo['attr_var_name']}">
                              <label class="layui-form-label">{$vo['attr_name']}</label>
                              {switch name="$vo['attr_input_type']" }
                                {case value="1"}

                                {/case}
                                {case value="2"}
                                <div class="layui-input-inline">
                                  <textarea name="{$vo['attr_var_name']}" id="{$vo['attr_var_name']}" class="layui-textarea">{$vo.value|default=''}</textarea>
                                </div>
                                {/case}
                                {case value="3"}
                                <div class="layui-input-inline">
                                  <div class="upload-box">
                                    <div class="upload-img fl">
                                      <div class="icaction none">
                                        <span class="load_images">
                                           <a href="javascript:void(0);" onclick="BigImages($('#img_{$vo['attr_var_name']}').attr('src'));">
                                           <i class="layui-icon layui-icon-search mr5"></i>查看
                                           </a>
                                        </span>
                                        <span class="load_images">
                                          <a href="javascript:void(0);" data-inputid="{$vo['attr_var_name']}" onclick="DelImages(this);">
                                          <i class="layui-icon layui-icon-delete mr5"></i>删除
                                          </a>
                                        </span>
                                      </div>
                                      <div class="cover-bg none"></div>
                                      <img id="img_{$vo['attr_var_name']}" src="{$vo.value|get_default_pic=###}">
                                    </div>
                                    <div class="upload-right fl">
                                      <button class="layui-btn test-upload-demoMore layui-btn-primary layui-btn-sm fl mb10 mr5" lay-data="{number:1,ey_inputId:'{$vo['attr_var_name']}',ey_savepath:'allimg'}"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                      <button class="layui-btn layui-btn-sm layui-btn-primary layui-btn-sm fl mb10" onClick="GetPictureFolder(1,'{$vo['attr_var_name']}');"><i class="layui-icon">&#xe64a;</i>图库</button>
                                      <input name="{$vo['attr_var_name']}" id="{$vo['attr_var_name']}" placeholder="图片地址" value="{$vo.value|default=''}" class="layui-input">
                                    </div>
                                  </div>
                                </div>
                                {/case}
                                {default /}
                                <div class="layui-input-inline">
                                  <input type="text" id="{$vo['attr_var_name']}" name="{$vo['attr_var_name']}" value="{$vo.value|default=''}" lay-verify="title" class="layui-input">
                                </div>
                              {/switch}
                            </div>
                            {/volist}
                            <div class="layui-form-item">
                              <label class="layui-form-label"><strong>第三方代码</strong></label>
                              <div class="layui-input-inline"></div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                              <label class="layui-form-label">电脑PC端</label>
                              <div class="layui-input-inline">
                                <textarea name="web_thirdcode_pc" id="web_thirdcode_pc" class="layui-textarea">{$config.web_thirdcode_pc|default=''}</textarea>
                              </div>
                              <div class="layui-input-inline layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">代码会放在 &lt;/body&gt; 标签以上（一般用于放置百度商桥代码、站长统计代码、谷歌翻译代码等）</div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                              <label class="layui-form-label">手机移动端</label>
                              <div class="layui-input-inline">
                                <textarea name="web_thirdcode_wap" id="web_thirdcode_wap" class="layui-textarea">{$config.web_thirdcode_wap|default=''}</textarea>
                              </div>
                              <div class="layui-input-inline layui-form-mid layui-word-aux ey_helptips"></div>
                              <div class="layui-form-inline2 ey_helptips_txt">代码会放在 &lt;/body&gt; 标签以上（一般用于放置百度商桥代码、站长统计代码、谷歌翻译代码等）</div>
                            </div>
                            <div class="layui-form-item">
                              <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
     </div>
  </div>

<script type="text/javascript">

  $(document).ready(function(){
      // 鼠标事件，加载查看大图和删除图片
      $(".upload-img").live('mouseover', function(){
          $(this).find('div.icaction').show();
          $(this).find('div.cover-bg').show();
      }).live('mouseout', function(){
          $(this).find('div.icaction').hide();
          $(this).find('div.cover-bg').hide();
      });
  });

  layui.config({
    base: '__SKIN__/' //静态资源所在路径
    ,version: '{$version}'
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,layer = layui.layer
    ,form = layui.form;

    tipsText();

    /* 触发事件 */
    var active = {
      customvar_index: function(){
        //iframe窗
        var iframes = layer.open({
            type: 2,
            title: '自定义变量列表',
            fixed: true, //不固定
            shadeClose: false,
            shade: 0.3,
            content: "{:url('System/customvar_index')}",
            end: function(){
              layer_loading();
              window.location.reload();
            }
        });
        layer.full(iframes);
      }
    };

    $('#LAY-component-layer-list .layui-btn').on('click', function(){
      var type = $(this).data('type');
      active[type] && active[type].call(this);
    });

    // 监听开关
    form.on('switch', function(data){
      var elemId = data.elem.attributes['lay-filter']['nodeValue'];
      if (data.elem.checked) {
        this.value = 1;
      } else {
        this.value = 0;
      }
      $("input[name='"+elemId+"']").val(this.value);
    });

    //监听提交
    form.on('submit(formSubmit)', function(data){
        var load = layer_loading();
        data.field._ajax = 1;
        $.ajax({
            type : 'post',
            url : "{:url('System/web')}",
            data : data.field,
            dataType : 'json',
            success : function(res){
                layer.close(load); //关闭loading
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                        window.location.reload();
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.close(load); //关闭loading
                showErrorAlert();
            }
        });
        return false;
    });
    
  });
  </script>

{include file="public/footer" /}
